﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArchUtils.Utils;

namespace YJKElementFinish.MultiWallEdit.Controller
{
	public class ExtendXYZComparer : IEqualityComparer<XYZ>
	{
		public ExtendXYZComparer(int decimalPlaces = 4)
		{
			this.m_EPSDecimalPlaces = decimalPlaces;
			string text = "0.";
			for (int i = 0; i < decimalPlaces; i++)
			{
				text += "0";
			}
			this.m_StrEPS = "#" + text;
			text += "1";
			this.m_EPS = double.Parse(text);
		}

		public bool Equals(XYZ p, XYZ q)
		{
			return Geometry.IsEqual(p.DistanceTo(q), 0.0, this.m_EPS);
		}

		public int GetHashCode(XYZ p)
		{
			string text = p.X.ToString(this.m_StrEPS);
			string text2 = p.Y.ToString(this.m_StrEPS);
			string text3 = p.Z.ToString(this.m_StrEPS);
			return string.Concat(new string[]
			{
				"(",
				text,
				",",
				text2,
				",",
				text3,
				")"
			}).GetHashCode();
		}

		private int m_EPSDecimalPlaces = 4;

		private double m_EPS = 0.0001;

		private string m_StrEPS = "#0.0000";
	}
}
